//
//  SandboxHandler.m
//  UI15_SandBox_NSFileManager_NSFileHandler
//
//  Created by Scott on 16/3/29.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "SandboxHandler.h"

@implementation SandboxHandler

#pragma mark - Creating and Init 
+ (instancetype)sandBoxHandler {
    
    SandboxHandler *sand = [[SandboxHandler alloc] init];
    
    return sand;
}

#pragma mark - path 


+ (NSString *)saveInDocumentsWithFileName:(NSString *)name {
    
    return [[SandboxHandler pathOfDocuments] stringByAppendingPathComponent:name];
}

+ (NSString *)pathOfDocuments {
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

}








/** 获取app的Sandbox路径. */
- (NSString *)pathOfAppSandbox {
    
    // 核心API: 函数 NSHomeDirectory
    
    return NSHomeDirectory();
    
}

/** 获取Documents 路径. */
- (NSString *)pathOfDocuments {
    
    // 核心API:  NSSearch....
    
  return [SandboxHandler pathOfDocuments];
    
}

/** 获取Tmp 路径. */
- (NSString *)pathOfTemp {
    
    // Core API: NSTemporaryDirectory
    return NSTemporaryDirectory();
}

/** 获取Library 路径. */
- (NSString *)pathOfLibrary {
    
    return [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
}

/** 获取Caches 路径. */
- (NSString *)pathOfCaches {
    
    return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    
    
}

/** 获取Preferences 路径. */
- (NSString *)pathOfPreferences {
    
    // 拼接字符串
    return [[self pathOfLibrary] stringByAppendingPathComponent:@"Preferences"];
    
}

/** 获取 App 包路径. */
- (NSString *)pathOfAppBundle {
    
    return [NSBundle mainBundle].resourcePath;
    
}







@end
